
$(function () {
    if (u.indexOf('iPhone') > -1) {   //苹果手机

    }else {
        //jsObj.setRight('历史试模','testHistory.html');
    }
    //收起，展开
    $('.main').on('click','.isShow',function () {
        if($(this).html()=='收起'){
            $(this).siblings('.contentBox').hide();
            $(this).html('展开');
        }else{
            $(this).siblings('.contentBox').show();
            $(this).html('收起');
        }
    });

    var url='/test/mode/record/detail';
    var mdObj=md5Fun(appUserId,url,appToken);
    var parameterObj= {
        "id":localStorage.historyId,
    };
    var parameter=Encrypt(JSON.stringify(parameterObj));
    console.log(Decrypt(parameter));
    $.ajax({
        type: "POST",
        timeout : 5000,
        url: webUrlCon+url,
        data:JSON.stringify(
            {"parameter":parameter}
        ),
        beforeSend: function(request) {
            request.setRequestHeader("Content-Type", "application/json");
            request.setRequestHeader("sequence", mdObj.sequence);
            request.setRequestHeader("nonceStr", mdObj.nonceStr);
            request.setRequestHeader("userId", appUserId);
            request.setRequestHeader("token",appToken);
            //xmlhttp.setRequestHeader("infName", url);
            //xmlhttp.setRequestHeader("osVersion", '');
            request.setRequestHeader("versionType", "1");
            request.setRequestHeader("osPlatform", mdObj.osPlatform);
            request.setRequestHeader("appVersion", mdObj.appVersion);
            request.setRequestHeader("sign", mdObj.sign);
        },
        success: function (data) {
            //layer.closeAll();
            $('.spinner').hide();
            $('.main').show();
            console.log(data);
            if(data.code==100){
                content=Decrypt(data.content);
                //alert(content);
                content=JSON.parse(content);
                console.log(content)
                var testInfoHtml='<li>' +
                    '<div class="title">试模产品编号：'+localStorage.assemblCode+'</div>' +
                    '<div class="content">' +
                    '<p><span>产品名称：</span>'+localStorage.productName+'</p>' +
                    '<p><span>产品编号：</span>'+localStorage.productCode+'</p>' +
                    '<p><span>生产单号：</span>'+localStorage.productOrderCode+'</p>' +
                    '<p><span>零件总数：</span>'+localStorage.partCount+'</p>' +
                    '<p><span>完成试模：</span>'+localStorage.modeNum+'</p>' +
                    '</div>' +
                    '</li>';
                if(content.length>0){
                    for (var i=0;i<content.length;i++){
                        if(content[i].status==2){
                            testInfoHtml+='<li class="testT">' +
                                '<div class="title">T0试模：'+content[i].factHours+'h  '+formatDateTime(content[i].startDate)+'开始</div>' +
                                '<div class="isShow">展开</div>' +
                                '<div class="contentBox" style="display:none;">' +
                                '<div class="content">' +
                                '<p class="group">问题负责组别：<span id="group">'+content[i].deptName+'、'+content[i].groupName+'</span></p>' +
                                '</div>';

                            if(content[i].modeImg!=''){
                                testInfoHtml+='<div class="content">' +
                                    '<p>试模图片</p>' +
                                    '<div class="testImages">';
                                var modeImg=content[i].modeImg.split(',');
                                for(var k=0;k<modeImg.length;k++){
                                    testInfoHtml+='<div class="img"><img onclick="zoomAlert(this)" src="'+ossUrl+modeImg[k]+'" /></div>';
                                }
                                testInfoHtml+='</div>' +
                                    '</div>';
                            }
                            if(content[i].content!=''){
                                testInfoHtml+='<div class="content">' +
                                    '<p>试模报告</p>' +
                                    '<p class="testReport">'+content[i].content+'</p>' +
                                    '</div>';
                            }
                            testInfoHtml+='</div>' +
                                '</li>'
                        }
                    }
                }
                $('.TabMainUl').html(testInfoHtml);
            }else{
                layer.open({
                    content: data.code+' '+data.message
                    ,btn: '确定'
                });
            }
        },
        error: function(e) {
            //layer.closeAll();
            $('.spinner').hide();
            layer.open({
                content: '无法请求服务器，请稍后再试！'
                ,btn: '确定'
            });
        }
    });


})



lazyLoadInit({
    coverColor:"white",
    offsetBottom:0,
    offsetTopm:0,
    showTime:10,
    onLoadBackEnd:function(i,e){
        //console.log("onLoadBackEnd:"+i);
    }
    ,onLoadBackStart:function(i,e){
        //console.log("onLoadBackStart:"+i);
    }
});
